//
//  GrowlObserver.m
//  Do Not Disturb
//
//  Created by Chris Karr on 8/29/07.
//  Copyright 2007 __MyCompanyName__. All rights reserved.
//

#import "GrowlObserver.h"
#import "DNDDefines.h"

@implementation GrowlObserver

- (GrowlObserver *) init
{
	if (self = [super init])
	{
		[[NSDistributedNotificationCenter defaultCenter] addObserver:self selector:@selector(handleNotification:) 
			name:@"DNDGrowlNotification" object:nil];
	}
	
	return self;
}

- (NSString *) getName
{
	return @"Growl";
}

- (void) scan
{

}

- (void) handleNotification:(NSNotification *) msg
{
	NSDictionary * note = [msg userInfo];
	
	NSMutableDictionary * dict = [NSMutableDictionary dictionary];
	[dict setValue:[NSDate date] forKey:@"date"];
	[dict setValue:[NSString stringWithFormat:@"Growl (%@): [%@] %@", [note valueForKey:@"ApplicationName"],
		[note valueForKey:@"NotificationTitle"], [note valueForKey:@"NotificationDescription"]] forKey:@"name"];
	[dict setValue:note forKey:@"object"];

	[[NSDistributedNotificationCenter defaultCenter] postNotificationName:DND_UPDATE object:@"GrowlObserver" userInfo:dict];
}


@end
